<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Find Customer"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="Customer Name" for="customerName" />
                    <p:autoComplete id="customerName" value="#{customersController.customerName}" completeMethod="#{customersController.autocomplete}"/>
                </h:panelGrid>
                <h:commandButton action="#{customersController.search}" value="Search" />
                <h:panelGroup rendered="#{customersController.searchItems.rowCount > 0}">
                    <h:outputText value="#{customersController.searchPagination.pageFirstItem + 1}..#{customersController.searchPagination.pageLastItem + 1}/#{customersController.searchPagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{customersController.previous}" value="#{bundle.Previous} #{customersController.searchPagination.pageSize}" rendered="#{customersController.searchPagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{customersController.next}" value="#{bundle.Next} #{customersController.searchPagination.pageSize}" rendered="#{customersController.searchPagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{customersController.searchItems}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCustomersTitle_custId}"/>
                            </f:facet>
                            <h:outputText value="#{item.custId}"/>
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCustomersTitle_name}"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </h:column>
                        
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListCustomersTitle_description}"/>
                            </f:facet>
                            <h:outputText value="#{item.description}"/>
                        </h:column>
                       
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{customersController.prepareView}" value="#{bundle.ListCustomersViewLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{customersController.prepareEdit}" value="#{bundle.ListCustomersEditLink}"/>
                            <h:outputText value=" "/>
                            <h:commandLink action="#{customersController.destroy}" value="#{bundle.ListCustomersDestroyLink}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <h:commandButton value="Back to Home" action="/index" />
            </h:form>
        </ui:define>
    </ui:composition>
</html>
